package Gui;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JTextField;

import ControlLayer.GuestCtr;

import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.RowSpec;

import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

public class Registers extends JPanel {
	

	private JTextField textField;
	private JTextField textField_1;
	private JTextField textField_2;
	private JTextField textField_3;
	private JTextField textField_4;
	private JTextField textField_5;
	private JTextField textField_6;
	private JLabel lblFirstName;
	private JLabel lblLastName;
	private JLabel lblAddress;
	private JLabel lblCountry;
	private JLabel lblPhone;
	private JLabel lblEmail;
	private JLabel lblTravelAgency;
	private JButton button;
	
	private GuestCtr gCtr;

	/**
	 * Create the panel.
	 */
	public Registers() {
		gCtr = new GuestCtr();
		
		setLayout(new FormLayout(new ColumnSpec[] {
				ColumnSpec.decode("66px"),
				ColumnSpec.decode("95px"),
				ColumnSpec.decode("99px:grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				ColumnSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,
				FormFactory.RELATED_GAP_COLSPEC,
				FormFactory.DEFAULT_COLSPEC,},
			new RowSpec[] {
				RowSpec.decode("max(32dlu;default)"),
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				FormFactory.DEFAULT_ROWSPEC,
				FormFactory.RELATED_GAP_ROWSPEC,
				RowSpec.decode("default:grow"),}));
		
		lblFirstName = new JLabel("First Name");
		add(lblFirstName, "2, 2");
		
		textField = new JTextField();
		add(textField, "3, 2, fill, default");
		textField.setColumns(10);
		
		lblLastName = new JLabel("Last Name");
		add(lblLastName, "2, 4");
		
		textField_1 = new JTextField();
		textField_1.setColumns(10);
		add(textField_1, "3, 4, fill, default");
		
		lblAddress = new JLabel("Address");
		add(lblAddress, "2, 6, left, default");
		
		textField_2 = new JTextField();
		textField_2.setColumns(10);
		add(textField_2, "3, 6, fill, default");
		
		lblCountry = new JLabel("Country");
		add(lblCountry, "2, 8, left, default");
		
		textField_3 = new JTextField();
		textField_3.setColumns(10);
		add(textField_3, "3, 8, fill, default");
		
		lblPhone = new JLabel("Phone");
		add(lblPhone, "2, 10, left, default");
		
		textField_4 = new JTextField();
		textField_4.setColumns(10);
		add(textField_4, "3, 10, fill, default");
		
		lblEmail = new JLabel("E-mail");
		add(lblEmail, "2, 12, left, default");
		
		textField_5 = new JTextField();
		textField_5.setColumns(10);
		add(textField_5, "3, 12, fill, default");
		
		lblTravelAgency = new JLabel("Travel agency");
		add(lblTravelAgency, "2, 14");
		
		textField_6 = new JTextField();
		textField_6.setColumns(10);
		add(textField_6, "3, 14, fill, default");
		
		button = new JButton("Save");
		button.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				gCtr.insertGuest(textField.getText(), textField_1.getText(), textField_2.getText(), textField_3.getText(), textField_4.getText(), textField_5.getText(), textField_6.getText());
			}
		});
		add(button, "7, 18");

	}

}
